package com.wpp.mq.kafka.consumer;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: WangPengPeng
 * @create: 2021-12-12 20:57
 **/
@Component
public class ConsumerListener {

    @KafkaListener(topics = "topic-spring-01")
    public void onMessage(ConsumerRecord<Integer, String> record) {
        System.out.println("消费者收到的消息 "
                    + "topic: " + record.topic() + "\t"
                    + "partition: " + record.partition() + "\t"
                    + "offset: " + record.offset() + "\t"
                    + "key: " + record.key() + "\t"
                    + "value: " + record.value());
    }
    @KafkaListener(topics = "topic-spring-02")
    public void onMessageSecond(ConsumerRecord<Integer, String> record) {
        System.out.println("消费者收到的消息："
                + "topic: " + record.topic() + "\t"
                + "partition: " + record.partition() + "\t"
                + "offset: " + record.offset() + "\t"
                + "key: " + record.key() + "\t"
                + "value: " + record.value());
    }

}
